\section{Testing}
In the following section we cover white-box and black-box testing of our
program. We have used informal/ad hoc methods for testing units throughout
development. In this way we have discovered several mistakes and errors, some
syntactic, some semantic. The formal testing was done after coding was
completed.\\

\subsection{White-Box Testing}
White-box testing, or structural testing, relies on access to the source code of
the program to be tested. According to \cite{Test} \emph{"The goal of structural
test is to make sure that all parts of the program have been executed."} We
limit our analysis to the \texttt{put} and \texttt{get} methods of the class
\texttt{StaticHashTable}. We are aware that a thorough analysis would have to
cover all our source code but deem this to be outside the scope of the project
cluster. The goal of this section is hence to show our understanding of
white-box testing rather than a complete white-box test.\\

Our choice of analysing the \texttt{put} and \texttt{get} methods of the
\texttt{StaticHashTable} class does cover important parts of the source code, including use of data
structures \texttt{LinkedList}, \texttt{URLList} and \texttt{NestedLinkedList}.
Further, the code for the put and get methods share large parts with the put and get methods in our
searchers for the other data structures.\\

In figure \ref{whitebox_put_code} is listed the code for the \texttt{put(String
key, String value)} method. It contains choice statements as specified in
figure \ref{whitebox_put_property}, which we have tested using test data
specified in figure \ref{whitebox_put_data}. In figure \ref{whitebox_get_code}
is listed the code for the \texttt{get(String key)} method. It contains choice statements as specified in
figure \ref{whitebox_get_property}, which we have tested using test data
specified in figure \ref{whitebox_get_data}.\\

 In figure \ref{whitebox_test_code} is listed part of the code for
\texttt{whiteboxText.java}, which was used for the white-box test. The results
were as expected. 

\begin{figure}
\lstinputlisting[firstline=24,lastline=56,firstnumber=24]{../../src/test/whiteboxTest.java}
\caption{ Excerpt of code for white-box test.}\label{whitebox_test_code}
\end{figure}


\begin{figure}
\lstinputlisting[firstline=39,lastline=77,firstnumber=39]{../../src/model/searchers/advancedSearchers/hashTableSearchers/StaticHashTable.java}
\caption{ \texttt{StaticHashTable.put( String key , String value
)}}\label{whitebox_put_code}
\end{figure}


\begin{figure}
%%TO  INPUT A TABLE
\begin{center} %centrerer tabellen
 \fontsize{9}{11}\selectfont
\begin{tabular}{|l|c|l|}
\hline
 \textbf{Choice} & \textbf{Input Data Set} & \textbf{Input Property}\\
\hline 
false & A & Array index empty \\
true & B & Array index not empty \\
true & B &  The word does not exist\\
false & C &  The word does exist \\
false & C &  The URL does not exist\\
true & D &  The URL does exist \\
\hline
\end{tabular}
\end{center}
\caption{Choice statements for \texttt{StaticHashTable.put( String
key, String value)}}\label{whitebox_put_property}
\end{figure}

\begin{figure}
%%TO  INPUT A TABLE
\begin{center} %centrerer tabellen
 \fontsize{9}{11}\selectfont
\begin{tabular}{|l|c|l|}
\hline
 \textbf{Input Data Set} & \textbf{Contents} & \textbf{Expected Output}\\
\hline 
A & ("Ovn","URL1") & element created in index 7\\
B & ("Grethe","URL1") & element created as first in linked list in index 7\\
C & ("Grethe","URL2") & element with matching key (search word)\\ & & is
added another value (URL2)\\
D & ("Grethe","URL2") & element with matching key (search word)\\ & & has
occurences for value (URL2) updated\\
\hline
\end{tabular}
\end{center}
\caption{Choice statements for \texttt{StaticHashTable.put( String
key, String value)}}\label{whitebox_put_data}
\end{figure}

\begin{figure}
\lstinputlisting[firstline=86,lastline=100,firstnumber=86]{../../src/model/searchers/advancedSearchers/hashTableSearchers/StaticHashTable.java}
\caption{ \texttt{StaticHashTable.get( String key )}}\label{whitebox_get_code}
\end{figure}

\begin{figure}
%%TO  INPUT A TABLE
\begin{center} %centrerer tabellen
 \fontsize{9}{11}\selectfont
\begin{tabular}{|l|c|l|}
\hline
 \textbf{Choice} & \textbf{Input Data Set} & \textbf{Input Property}\\
\hline 
true & A & Array index not empty \\
false & B & Array index empty \\
zero times & - & \emph{Always true if reached}\\
one time & C & Only one element in array index\\
more than once & A & More than one element in array index\\
false & C & Key does not match element value \\
true & D & Key matches element value\\
\hline
\end{tabular}
\end{center}
\caption{Choice statements for \texttt{StaticHashTable.get( String
key)}}\label{whitebox_get_property}
\end{figure}

\begin{figure}
%%TO  INPUT A TABLE
\begin{center} %centrerer tabellen
 \fontsize{9}{11}\selectfont
\begin{tabular}{|l|c|l|}
\hline
 \textbf{Input Data Set} & \textbf{Contents} & \textbf{Expected Output}\\
\hline 
A & \texttt{get}("Ovn") & URL1\\ 
B & \texttt{get}("Hans") & \texttt{null}\\
C & \texttt{put}("Sti") + \texttt{get}("Hans") & \texttt{null}\\
D & \texttt{put}("Sti") + \texttt{get}("Sti") & URL\\

\hline
\end{tabular}
\end{center}
\caption{Choice statements for \texttt{StaticHashTable.get( String
key)}}\label{whitebox_get_data}
\end{figure}

